This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
#include <windows.h>
#include <ddraw.h>
#include "blending.h"
#include "canvas.h"
#include "bitmap.h"
#include "region.h"
#include "basewnd.h"
#include "fontdef.h"
#include "../studio/assert.h"
#include "../studio/api.h"
#define CBCLASS Canvas
START_DISPATCH;
CB(GETHDC, getHDC);
CB(GETROOTWND, getRootWnd);
CB(GETBITS, getBits);
VCB(GETOFFSETS, getOffsets);
CB(ISFIXEDCOORDS, isFixedCoords);
CB(GETDIM, getDim);
CB(GETTEXTFONT, getTextFont);
CB(GETTEXTSIZE, getTextSize);
CB(GETTEXTBOLD, getTextBold);
CB(GETTEXTOPAQUE, getTextOpaque);
CB(GETTEXTALIGN, getTextAlign);
CB(GETTEXTCOLOR, getTextColor);
END_DISPATCH;
#undef CBCLASS
//NONPORTABLE
Canvas::Canvas() {
hdc = NULL;
bits = NULL;
srcwnd = NULL;
fcoord = FALSE;
xoffset = yoffset = 0;
align = DT_LEFT;
tsize = 12;
tbold = 0;
topaque = 0;
width=height=pitch=0;
tcolor = RGB(0,0,0);
tfont = new String; // using dynamic tfont here coz we need to manage em with stack, so stacking fonts won't take sizeof(String) and their destruction will not fuxor everything
tfont->setValue("Arial");
// tvariable = 0;
}
Canvas::~Canvas() {
ASSERT(hdc == NULL);
delete tfont;
if (!fontstack.isempty()) {
OutputDebugString("Font stack not empty in Canvas::~Canvas !");
while (!fontstack.isempty()) {
String *s;
fontstack.pop(&s);
delete s;
}
}
if (!boldstack.isempty() || !opstack.isempty() || !alstack.isempty() || !colorstack.isempty() || !sizestack.isempty())
OutputDebugString("Font property stack not empty in Canvas::~Canvas !");